<?php
class Joomzf_Controller_Component {
	
	public $component;
	public $action;
	public $view;
	public $request;
	public $template;
	
	public $option;
	
	public $renderView;
	public $title;
	public function __construct($component){
		$this->component					= $component;
		
		$this->action 						= $component->action;
		$this->view 						= $component->view;
		$this->request 						= $component->request;
		$this->option						= $component->getLink();
		
		
		$this->renderView					= $this->option->activity;

// 		$this->option->mainActivity = 'http://'.$_SERVER[HTTP_HOST].$this->view->jfUrl(
// 				array('activity'=>'index'),
// 				'admin-'.$this->component['name'].'-'.$this->component['control'].'-'.$this->component['activity']
// 				,array('kaka'=>5),true);
		$activity = $this->option->activity."Activity";
		$this->init();
		$this->$activity();
		$this->postDispath();
		if($this->renderView != false) $this->loadView();
	}
	public function init(){

	}
	public function postDispath(){
		$this->view->headTitle($this->title,true);
	}
	public function loadView(){
		$this->component->setLinkRenderView($this->renderView);
		require(Joomzf_Component::getLayout($this->component));
	}
	
	public function addTitle($title){
		$this->title .= $title;
	}
	public function setTitle($title){
		$this->title = $title;
	}
	public function getModel($model = null){
		if($model != null){
			require "model".DS.$model.".php";
			
			return new $model();
		}
		return false;
	}
}